import React, { Component } from 'react';

// setState() 是异步更新数据的
// 注意：🔔使用该语法时，后面的 setState() 不要依赖于前面的 setState()
export default class App extends Component {
  state = {
    count: 0,
  };

  handleClick = () => {
    this.setState({ count: this.state.count + 1 }, () => {
      console.log('this.state.count----', this.state.count);
      document.title = this.state.count;
    });
  };
  render() {
    return (
      <div>
        <h1>数量：{this.state.count}</h1>
        <button onClick={this.handleClick}>点我</button>
      </div>
    );
  }
}
